var ns, app,toast;
app = new Vue({
    el: '#app',
    data:{

        UserName:'',
        typeList:[
            // {id:2,title:'优惠减免',type:2,msgdec:1},
            {id:6,title:'人事申请',type:20,msgdec:'员工请假申请'},
            {id:8,title:'绩效嘉奖',type:22,msgdec:'工单好评等奖励申请'},
            {id:7,title:'绩效处罚',type:21,msgdec:'处罚申请'},
            {id:5,title:'通用申请',type:18,msgdec:'基本审核申请'},
            {id:4,title:'用印申请',type:19,msgdec:'印章、公章、法人证件使用申请'},
            {id:3,title:'采购申请',type:1,msgdec:'物品采购提前申请'},
        ],
        StaffID:0,
        StaffName:'',

    },
    methods:{
        do_open_add: function(type) {
            var that=this;
            //采购申请
            if(type==1){
                ns.openWin('purchase_add', '采购申请');
            }else if(type==19){
                ns.openWin('seal_add', '用印申请');
            }else if(type==18){
                ns.openWin('common_add', '通用申请');
            }else if(type==20){
                if(that.StaffID>0){
                    ns.openWin('leave_add', '请假申请',{
                        StaffID:that.StaffID
                    });
                }else{
                    api.toast({
                        msg: '请绑定员工',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }else if(type==21){
                if(that.StaffID>0){
                    ns.openWin('punishment_add', '处罚申请',{
                        StaffID:that.StaffID,
                        StaffName:that.StaffName
                    });
                }else{
                    api.toast({
                        msg: '请绑定员工',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }else if(type==22){
                if(that.StaffID>0){
                    ns.openWin('Reward_add', '奖励申请',{
                        StaffID:that.StaffID,
                        StaffName:that.StaffName
                    });
                }else{
                    api.toast({
                        msg: '请绑定员工',
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }
        },
        get_user_data: function () {
            var that = this;
            // 是否绑定员工
            var StaffID = api.getPrefs({
                sync: true,
                key: 'StaffID'
            });
            var StaffName = api.getPrefs({
                sync: true,
                key: 'StaffName'
            });
            that.StaffID = StaffID || 0;
            that.StaffName=StaffName;
        },
    },
});
apiready = function() {
    api.parseTapmode();
    toast = new auiToast();
    ns = window.Foresight.Util;
    app.get_user_data();
    api.addEventListener({
        name:'purchase_updata'
    }, function(ret){
        api.closeWin();
    })
};